#pragma once

#include "flui/ui_codetable_editfl.h"
#include "UIIpcClient.h"


class CodeTableEditUI {
public:
    CodeTableEditUI(UIIpcClient *ui_ipc_client);
    ~CodeTableEditUI();

    void init();

    /// @brief 显示码表编辑窗口
    /// @param code_table_id 码表id
    /// @param window_title 窗口标题
    void show(unsigned int code_table_id, const std::string &window_title); 

private:
    //按钮回调
    static void onMoveUpWord(Fl_Widget*, void*);
    static void onMoveDownWord(Fl_Widget*, void*);
    static void onSearchWords(Fl_Widget*, void*);
    static void onAddWord(Fl_Widget*, void*);
    static void onRemoveWord(Fl_Widget*, void*);
    // 新增回调声明
    static void onAddWordConfirm(Fl_Widget*, void*);
    static void onAddWordCancel(Fl_Widget*, void*);
    

    void refreshBrowser(); // 刷新浏览器显示


private:
    UIIpcClient *_ui_ipc_client;

    UICodeTableEditViewFL _codetable_edit_view;
    UIAddWordViewFL _add_word_view;  //添加词条窗口
    std::string _search_code;
    unsigned int _current_code_table_id; // 当前的码表id，
    std::vector<WubiCodetableData> _words; // 存储词条信息
    
};